﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Perceiveit.Xml.Converters
{


    #region public class DateTimeXConverter : XConverter<DateTime>

    public class DateTimeXConverter : XConverter<DateTime>
    {
        public override DateTime FromString(string value)
        {
            DateTime v;
            if (string.IsNullOrEmpty(value) || !DateTime.TryParse(value, out v))
                v = DateTime.MinValue;

            return v;
        }

        public override string ToString(DateTime value)
        {
            if (value == DateTime.MinValue)
                return string.Empty;
            else
                return value.ToString("yyyy-MM-ddThh:mm:ss");
        }
    }

    #endregion
}
